package gameOnline.persistance;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 * @author Amale El Bouffi
 */
@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findConnectPlayers", query = "select object(p) from Player p where p.status = :statut"),
    @NamedQuery(name = "findAllPlayers", query = "select object(p) from Player p"),
    @NamedQuery(name = "findPlayer", query = "select object(p) from Player p where p.login = :login and p.password = :password")
})
public class Player implements Serializable {
    @Id
    private String login;
    
    @Column(length=8)
    private String password;
    
    @Column(unique=true)
    private String email;
    
    @Basic
    private int nbGame, nbVictory;
    private PlayerStatus status;
    
    

    /**
     * Constructeur par défaut
     */
    public Player() {
        this.login = "";
        this.password = "";
        this.email = "";
        this.nbGame = 0;
        this.nbVictory = 0;
        this.status = PlayerStatus.OFFLINE;
    }
    
    public Player(String login, String password, String email) {
        this.login = login;
        this.password = password;
        this.email = email;
        this.nbGame = 0;
        this.nbVictory = 0;
        this.status = PlayerStatus.ONLINE;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getGame() {
        return nbGame;
    }

    public void setGame(int game) {
        this.nbGame = game;
    }

    public int getVictory() {
        return nbVictory;
    }

    public void setVictory(int victory) {
        this.nbVictory = victory;
    }

    public PlayerStatus getStatus() {
        return status;
    }

    public void setStatus(PlayerStatus status) {
        this.status = status;
    }
}
